<?php
class modelCollectDaum extends coreModel
{
    public function getGenre()
    {
        $sQuery = 'select * from genre';
        
        return $this->query($sQuery);
    }
    
    public function setGenre($sName, $iOldId)
    {
        if (empty($sName) || empty($iOldId)) return false;
        
        $sQuery = "
            insert into genre (
                name,
                old_id
            ) values (
                '".$sName."',
                '".$iOldId."'
            )
        ";
        
        $this->query($sQuery, 'exec');
        return $this->lastInsertId();
    }
    
    public function setWebtoon($aData)
    {
        if (empty($aData)) return false;
        
        $sQuery = "
            insert into webtoon (
                id,
                name,
                introduction,
                media,
                is_finish,
                start_dt,
                service_status,
                pay_yn,
                price,
                age_grade,
                average_score,
                image01,
                old_id
            ) values (
                '".$aData['id']."',
                '".$aData['name']."',
                '".$aData['introduction']."',
                '".$aData['media']."',
                '".$aData['is_finish']."',
                '".$aData['start_dt']."',
                '".$aData['service_status']."',
                '".$aData['pay_yn']."',
                '".$aData['price']."',
                '".$aData['age_grade']."',
                '".$aData['average_score']."',
                '".$aData['image01']."',
                '".$aData['old_id']."'
            )
        ";
        
        $this->query($sQuery, 'exec');
        return $this->lastInsertId();
    }
    
    public function setCategory($sName, $sType, $iOldId)
    {
        if (empty($sName) || empty($sType) || empty($iOldId)) return false;
        
        $sQuery = "
            insert into category (
                name,
                category_type,
                old_id
            ) values (
                '".$sName."',
                '".$sType."',
                '".$iOldId."',
            )
        ";
        
        $this->query($sQuery, 'exec');
        return $this->lastInsertId();
    }
    
    public function setArtist($aData)
    {
        if (empty($aData)) return false;
        
        $sQuery = "
            insert into artist (
                name,
                introduction,
                email,
                homepage,
                blog,
                cafe,
                fancafe,
                facebook,
                twitter,
                artist_type,
                old_id
            ) values (
                '".$aData['name']."',
                '".$aData['introduction']."',
                '".$aData['email']."',
                '".$aData['homepage']."',
                '".$aData['blog']."',
                '".$aData['cafe']."',
                '".$aData['fancafe']."',
                '".$aData['facebook']."',
                '".$aData['twitter']."',
                '".$aData['artist_type']."',
                '".$aData['old_id']."'
            )
        ";
        
        $this->query($sQuery, 'exec');
        return $this->lastInsertId();
    }
}